function register() {
    $.ajax({
            url: 'user/signUp',
            type: "POST",
            data: {
            	userName: $("#username").val(),
                password:$("#password").val(),
                repPassword:$("#password").val(),
                phoneNum:$("#myemail").val(),
                phoneCode:$("#checkcode").val()
            }
            ,
            success: function (data) {
            	console.log(data);
                switch (data['status']){
                    
                    case 0:
                        //alert("注册成功!");
                        window.location.href = "login.html";
                        break;
                    default:
                    	alert(data['msg']);
                        break;
                }
            }
            ,
            error: function (err) {
                console.log(err);
            }
        }
    );
}

function showPhoneMessage() {

    var testEmail = $("#myemail").val();
    var reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
    if (!reg.exec(testEmail)){
        $("#emailMessage").css("visibility","visible");
    }

}

function cancelEmailMessage() {
    $("#emailMessage").css("visibility","hidden");
}
function showPasswordMessage() {

    var testPassword = $("#password").val();
    var reg = /^[a-zA-Z0-9_]{6,12}$/;
    if (!reg.exec(testPassword)){
        $("#passwordMessage").css("visibility","visible");
    }

}

function cancelPasswordMessage() {
    $("#passwordMessage").css("visibility","hidden");
}
function showUsernameMessage() {

    var testUsername = $("#username").val();
    var reg = /^[A-Za-z0-9_\u4e00-\u9fa5]{2,8}$/;
    if (!reg.exec(testUsername)){
        $("#usernameMessage").css("visibility","visible");
    }

}

function cancelUsernameMessage() {
    $("#usernameMessage").css("visibility","hidden");
}

function sendCode() {

    $.ajax({
            url: 'user/sendSignUpPhoneCode',
            type: "POST",
            data: {
            	phoneNum:$("#myemail").val(),   
            	type:0
            }
            ,
            success: function (data) {
            	console.log(data);
                switch (data['status']){
                    case 0:
                    	alert("发送手机验证码成功");
                        break;
                    default:
                    	alert("发送手机验证码失败");
                        break;
                }
            }
            ,
            error: function (err) {
                console.log(err);
            }
        }
    );

}